//
//  ZZLog.swift
//  SwiftTest
//
//  Created by bym on 2019/8/7.
//  Copyright © 2019 ZZ. All rights reserved.
//

import Foundation

public func ZZSimpleLog<T>(_ log: T) {
	
	//        print(#file)    //获取当前print所在的文件路径
	//        print(#function)    //获取当前print所在的方法名称
	//        print(#line)    //获取当前print所在的行数
	///判断是否打印debug
	#if DEBUG
	print("😂😂😂\(log)")
	#endif
}

public func ZZLog<T>(_ log: T, fileName: String = #file, methodName: String =   #function, lineNumber: Int = #line) {
	
	//        print(#file)    //获取当前print所在的文件路径
	//        print(#function)    //获取当前print所在的方法名称
	//        print(#line)    //获取当前print所在的行数
	///判断是否打印debug
	#if DEBUG
	print("😂😂😂\n$info:\((fileName as NSString).pathComponents.last!) line:\(lineNumber) methodName:\(methodName) \n$content:\n\(log)")
	#endif
}

public func ZZLogItems(_ items: Any..., fileName: String = #file, methodName: String =   #function, lineNumber: Int = #line) {
	
	//        print(#file)    //获取当前print所在的文件路径
	//        print(#function)    //获取当前print所在的方法名称
	//        print(#line)    //获取当前print所在的行数
	///判断是否打印debug
	#if DEBUG
	print("😂😂😂info:\((fileName as NSString).pathComponents.last!) line:\(lineNumber) methodName:\(methodName)",items, separator: "----", terminator: "😆😆😆")
	
	#endif
}


public func ZZLogFunc(fileName: String = #file, methodName: String = #function, lineNumber: Int = #line) {
	
	//        print(#file)    //获取当前print所在的文件路径
	//        print(#function)    //获取当前print所在的方法名称
	//        print(#line)    //获取当前print所在的行数
	///判断是否打印debug
	#if DEBUG
	print("😂😂😂\n$info:\((fileName as NSString).pathComponents.last!) line:\(lineNumber) methodName:\(methodName)")
	#endif
}

public func ZZLogResps<T>(_ log:T,fileName: String = #file, lineNumber: Int = #line) {
	#if DEBUG
	//[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:responseObject options:kNilOptions error:nil] encoding:NSUTF8StringEncoding]
	guard let data:Data = try? JSONSerialization.data(withJSONObject: log, options:[]) else{
		return
	}
	let str = String.init(data: data, encoding: .utf8)
	print("😂😂😂\n$info:\((fileName as NSString).pathComponents.last!) line:\(lineNumber) \n$content:\n\(str ?? "data to string error")")
	#endif
}
